package com.hzhc.controller.statistics;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzhc.common.BaseController;
import com.hzhc.enumBean.ResultUtilCodeEnum;
import com.hzhc.service.CntrInfoService;
import com.hzhc.service.CntrLogService;
import com.hzhc.service.DeclareCarService;
import com.hzhc.utils.ResultUtil;
import com.hzhc.vo.CntrStatisticsVo;
import com.hzhc.vo.DeclareCarVo;
import com.hzhc.vo.ProductionVo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * @author dongcy
 * @date 2024/6/14 14:19
 * @description StatisticsController
 */
@RestController
@RequestMapping("/statistics")
@RequiredArgsConstructor
public class StatisticsController extends BaseController {

    private final DeclareCarService declareCarService;

    private final CntrLogService logService;

    private final CntrInfoService infoService;

    /**
     * 车辆进出统计-折线图yzs
     * @param vo
     * @return
     */
    @RequestMapping("/statisticsData")
    @ResponseBody
    public ResultUtil<Map<String, Object>> statisticsData(@RequestBody DeclareCarVo vo) {
        return ResultUtil.build(declareCarService.getStatisticsData(vo), ResultUtilCodeEnum.SUCCESS);
    }

    /**
     * 车辆进出统计-列表yzs
     * @param request
     * @param vo
     * @return
     */
    @RequestMapping("/getList")
    @ResponseBody
    public ResultUtil<List<DeclareCarVo>> getList(HttpServletRequest request, @RequestBody DeclareCarVo vo){
        Page<DeclareCarVo> page = new Page<>(vo.getPageIndex(),vo.getPageSize());
        List<DeclareCarVo> list = declareCarService.getList(page,vo);
        return ResultUtil.build(list,page.getTotal(),page.getPages(),ResultUtilCodeEnum.SUCCESS);
    }

    /**
     * 统计查询--生产日报表yzs
     * @param vo
     * @return
     */
    @RequestMapping("/getProductionList")
    @ResponseBody
    public ResultUtil<List<ProductionVo>> getProductionList(@RequestBody ProductionVo vo) {
        List<ProductionVo> list = logService.getProductionList(vo);
        return ResultUtil.build(list, ResultUtilCodeEnum.SUCCESS);
    }

    /**
     * 在场箱货主统计
     * @param request
     * @param vo
     * @return
     */
    @RequestMapping("/getComCntrList")
    public ResultUtil<List<CntrStatisticsVo>> getComCntrList(HttpServletRequest request, @RequestBody CntrStatisticsVo vo){
        List<CntrStatisticsVo> list = infoService.getComCntrList(vo);
        return ResultUtil.build(list,ResultUtilCodeEnum.SUCCESS);
    }

}
